<?php
/*
Template Name: Brand Category Page
*/
?>

<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */
 
global $currentpageid;
$currentpageid = get_the_ID();

get_header(); ?>

	<?php if($is_iphone) { ?>
    		<style>
				#main { width:1040px;float:left;margin:0px; }
			</style>
    <?php } ?>

	<style>
		.yarpp-related { display:none; }
	</style>

	<div id="primary" class="site-content">
		<div id="content" role="main">
        
        	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
				<header class="entry-header">
					<h1 class="entry-title"><?php the_title(); ?></h1>
                    <?php include 'social-block.php'; ?>
				</header>

				<?php the_content(); ?>
                
				<?php
	$brandpagelone = new WP_Query('post_type=page&post_parent='.$currentpageid.'&posts_per_page=-1&orderby=menu_order'); ?>
    <ul class="products">
	<?php while ($brandpagelone->have_posts()) : $brandpagelone->the_post(); ?>
    
            	<?php $productbrandimage = get_post_meta($post->ID, 'productbrandimage', true); ?>
            	<li class="product" style="height:260px;">
                	<a href="<?php the_permalink(); ?>">
                    	<?php if(get_post_meta($post->ID, 'productbrandimage', true)) { ?>
                            <img src="../<?php echo $productbrandimage ; ?>" alt="<?php the_title() ; ?> Products" width="150" />
                        <?php } else { ?>
                            <img src="/../wp-content/themes/siliconsolar/images/siliconsolar-logo300.jpg" alt="<?php the_title();?>" width="150" />
                        <?php } ?>
                        <h3 style="margin-bottom:10px;"><?php the_title(); ?></h3>
                    </a>
                    <a href="<?php the_permalink(); ?>" class="button">View Products</a>
                </li>
        
    <?php endwhile ?>
    </ul>
<?php wp_reset_postdata(); ?>
                
			</article>

		</div><!-- #content -->
        
	</div><!-- #primary -->
    
<?php get_sidebar(); ?>

<?php get_footer(); ?>